package com.chx.mapper;

import com.chx.annotation.AutoFill;
import com.chx.dto.UserPageQueryDto;
import com.chx.entity.Users;
import com.chx.enumeration.OperationType;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @Author cp-月入过万
 * @Date 2025/5/29
 */
@Mapper
public interface UserMapper {

    @Select("select * from users where username = #{username}")
    Users getByUsername(String username);

    @Insert("insert into users(username,password,real_name,phone,email,role_id,create_time,update_time,status)" +
            " values" +
            "(#{username},#{password},#{realName},#{phone},#{email},#{roleId},#{createTime},#{updateTime},#{status})")
    @AutoFill(OperationType.INSERT)
    void insert(Users users);

    @AutoFill(OperationType.UPDATE)
    void update(Users users);

    @Select("select * from users where user_id = #{id}")
    Users getById(Long id);

    Page<Users> pageQuery(UserPageQueryDto userPageQueryDto);
}
